package com.sky.mapper;


import com.sky.vo.DishNumberVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface ReportMapper {

    @Select("select sum(amount) from orders where order_time between #{begin} and #{end} and status = #{status}")
    Double sumByMap(Map<String, Object> map);

    @Select("select count(id) from user where create_time between #{begin} and #{end}")
    long userCountByMap(Map<String, Object> map);

    @Select("select count(id) from user where create_time<#{endTime}")
    long sumUserDaliyByMap(LocalDateTime endTime);


    @Select("select count(id) from orders where order_time between #{begin} and #{end}")
    Integer sumOrdersByMap(Map<String, Object> map);

    @Select("select count(id) from orders where order_time between #{begin} and #{end} and status = 5")
    Integer sumOrderValidsByMap(Map<String, Object> map);
    
    @Select("select id from orders where order_time between #{beginTime} and #{endTime} and status = 5")
    List<Long> listOrdersIdByTime(LocalDateTime beginTime, LocalDateTime endTime);

    List<DishNumberVO> getSalesTop10(List<Long> orderIds);
}
